<?php
	include_once "dataservice.php";
	
	class trangthai_db
	{
		public function Them($MaTrangThai, $TenTrangThai)
		{
			$sql = "INSERT INTO `tbl_trangthai`(`MaTrangThai`, `TenTrangThai`) 
					VALUES ('$MaTrangThai', '$TenTrangThai')";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function Xoa($MaTrangThai)
		{
			$sql = "DELETE FROM `tbl_trangthai` WHERE `MaTrangThai` = '$MaTrangThai'";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function LayDanhSach($MaTrangThai)
		{
			$sql = "SELECT * FROM `tbl_trangthai` WHERE 1 ";
			if($MaTrangThai != -1)
				$sql .= " AND MaTrangThai = '$MaTrangThai' ";
			$sql .= " ORDER BY MaTrangThai ASC";
			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}
	}
?>